<?php
declare(strict_types=1);

namespace Dreamcat\ApiDoc\Error;

use JetBrains\PhpStorm\ExpectedValues;
use JetBrains\PhpStorm\Pure;
use RuntimeException;
use Throwable;

/**
 * popo异常
 * @author vijay
 */
class PopoException extends RuntimeException
{
    /** @var int GET 的字段名不为能空 */
    public const GET_FIELD_CANT_EMPTY = 3001001;
    /** @var int PathVariable 的字段名不为能空 */
    public const PATH_FIELD_CANT_EMPTY = 3001002;
    /** @var int Header 的字段名不为能空 */
    public const HEADER_FIELD_CANT_EMPTY = 3001003;
    /** @var int Cookie 的字段名不为能空 */
    public const COOKIE_FIELD_CANT_EMPTY = 3001004;
    /** @var int Object 的字段名不为能空 */
    public const OBJECT_FIELD_CANT_EMPTY = 3001005;

    /**
     * @param string $message 异常信息
     * @param int $code 异常码
     * @param ?Throwable $previous 异常链的前一异常
     */
    #[Pure]
    public function __construct(
        string $message,
        #[ExpectedValues(valuesFromClass: self::class)]
        int $code,
        Throwable $previous = null
    ) {
        parent::__construct($message, $code, $previous);
    }
}

# end of file
